import request from "@/utils/request.ts";
import {
    orderInfoResponseData,
    submitOrderResponseData,
    qrcodeResponseData,
    orderListResponseData,
    orderStatusResponseData
} from "@/api/order/type.ts";

enum API{
    // 创建订单获取id的地址
    submitOrderId_url='/order/orderInfo/auth/submitOrder/',
    // 获取订单详细的地址
    orderInfo_url='/order/orderInfo/auth/getOrderInfo/',
    // 取消预约订单的地址
    cancel_order_url='/order/orderInfo/auth/cancelOrder/',
    // 生成二维码的地址
    qrcode_url='/order/weixin/createNative/',
    // 支付结果的地址
    pay_result_url='/order/weixin/queryPayStatus/',
    // 订单列表的地址
    orderList_url='/order/orderInfo/auth/',
    //订单状态的地址
    orderStatus_url='/order/orderInfo/auth/getStatusList'
}

// 创建订单获取id的请求
export const reqtSubmitOrderId=(hoscode:string,scheduleId:string,patientId:number)=>request.post<any,submitOrderResponseData>(API.submitOrderId_url+`${hoscode}/${scheduleId}/${patientId}`)

// 获取订单详细请求
export const reqOrderInfo=(id:number)=>request.get<any,orderInfoResponseData>(API.orderInfo_url+`${id}`)

//取消预约订单的请求
export const reqCancelOrder=(orderId:string)=>request.get<any,any>(API.cancel_order_url+`${orderId}`)

//生成二维码的请求
export const reqQrcode=(orderId:string)=>request.get<any,qrcodeResponseData>(API.qrcode_url+`${orderId}`)

//查询支付结果的请求
export const reqPayResult=(orderId:string)=>request.get<any,any>(API.pay_result_url+`${orderId}`)

//获取订单列表的请求
export const reqOrderList=(page:number,limit:number,patientId:number,orderStatus:number)=>request.get<any,orderListResponseData>(API.orderList_url+`${page}/${limit}/?patientId=${patientId}&orderStatus=${orderStatus}`)

//获取订单状态的请求
export const reqOrderStatus=()=>request.get<any,orderStatusResponseData>(API.orderStatus_url)